﻿package com.eitb.programas.streaming{
	import flash.display.*;
	import flash.text.*;
	import com.eitb.programas.*;
	import com.eitb.literales.*;
	import com.eitb.programas.streaming.literales.*;
	import com.eitb.programas.streaming.formatos.*;
	import com.eitb.properties.*;
	
	public class Main extends Sprite {
		private static const CUATROTERCIOS:String = "cuatrotercios";
		private static const DIECISEISNOVENOS:String = "dieciseisnovenos";
		private static const RADIO:String = "";
		
/*		private var formato:String=loaderInfo.parameters.formato;
		private var hostname:String=loaderInfo.parameters.hostname;
		private var filename:String=loaderInfo.parameters.filename;
		private var idioma:String=loaderInfo.parameters.idioma;
		private var _scCG:String=loaderInfo.parameters.nombre;*/
		
		private var formato:String="dieciseisnovenos";
		private var hostname:String="cp70268.live.edgefcs.net/live";
		private var filename:String="eitb-CanalVasco@5519";
		private var _scCG:String=ModeloStreaming.CANAL_VASCO;
		private var idioma:String="es";

//		private var formato:String="cuatrotercios";
//		private var hostname:String="cp70268.live.edgefcs.net/live";
//		private var filename:String="eitb-CanalVasco@5519";
//		private var _scCG:String = ModeloStreaming.CANAL_VASCO;
//		private var idioma:String="es";

//		private var formato:String="";
//		private var hostname:String="cp70268.live.edgefcs.net/live";
//		private var filename:String="eitb-Radio-Euskadi@5539";
//		private var _scCG:String=ModeloStreaming.RADIO_VITORIA;// nombredelcanal;
//		private var idioma:String="en";

		private static var vStreaming:IVistaStreaming;
		private var videoFormat:IVideoProperties;
		private var logoFormat:ILogoProperties;
		private var esloganFormat:ILogoProperties;
		private var literales:StreamingLiterales;
		
		public function Main():void  {
			this.initStreaming();
		}
		private function initStreaming():void {
			var mStreaming:ModeloStreaming= new ModeloStreaming();
			var dStreaming:DialogoStreaming = new DialogoStreaming();
			addChild(dStreaming);

			dStreaming.initControladorStreaming(mStreaming);
			mStreaming.initVistaStreaming(dStreaming);
			
			switch (this.idioma) {
				case "es" :
					mStreaming.initIdioma(Literales.ES);
					literales = new StreamingLiterales(Literales.ES);
					break;
				case "en" :
					mStreaming.initIdioma(Literales.EN);
					literales = new StreamingLiterales(Literales.EN);
					break;
				case "fr" :
					mStreaming.initIdioma(Literales.FR);
					literales = new StreamingLiterales(Literales.FR);
					break;
				case "eu" :
					mStreaming.initIdioma(Literales.EU);
					literales = new StreamingLiterales(Literales.EU);
					break;
				default :
					mStreaming.initIdioma(Literales.EN);
					literales = new StreamingLiterales(Literales.EN);
			}
			
			switch (this.formato) {
				case Main.CUATROTERCIOS :
					this.videoFormat = new Cuatrotercios();
					break;
				case Main.DIECISEISNOVENOS :
					this.videoFormat = new Dieciseisnovenos();
					break;
				case Main.RADIO :
					this.videoFormat = new Radio();
					break;
				default :
			}
			
			switch(this._scCG) {
				case ModeloStreaming.GAZTEA:
					this.logoFormat = new GazteaLogo();
				break;
				case ModeloStreaming.EITB_MUSIKA:
				case ModeloStreaming.EUSKADI_IRRATIA:
				case ModeloStreaming.RADIO_EUSKADI:
				case ModeloStreaming.RADIO_VITORIA:
					this.logoFormat = new PajaroLogo();
				break;
				case ModeloStreaming.CANAL_VASCO:
				case ModeloStreaming.ETB_SAT:
					this.logoFormat = new SinLogo();
				break;				
			}			
			
			switch(this._scCG) {
				case ModeloStreaming.EITB_MUSIKA:
					this.esloganFormat = new EitbMusikaEslogan();
				break;
				case ModeloStreaming.EUSKADI_IRRATIA:
					this.esloganFormat = new EuskadiIrratiaEslogan();
				break;
				case ModeloStreaming.RADIO_EUSKADI:
					this.esloganFormat = new RadioEuskadiEslogan();
				break;
				case ModeloStreaming.RADIO_VITORIA:
					this.esloganFormat = new RadioVitoriaEslogan();
				break;
				case ModeloStreaming.CANAL_VASCO:
				case ModeloStreaming.ETB_SAT:
					this.esloganFormat = new SinLogo();
				break;
			}
			
			mStreaming.initFormato(this.videoFormat);
			mStreaming.initHostname(this.hostname);
			mStreaming.initFilename(this.filename);
			mStreaming.initCanal(this._scCG);
			mStreaming.initNielsen(this._scCG);
			mStreaming.initAkamai();
			
			dStreaming.initStage(this.videoFormat);
			dStreaming.initBackground(this.videoFormat);
			dStreaming.initVolumeSlider(this.videoFormat);
			dStreaming.initTimeDisplay(this.videoFormat);
			dStreaming.initBufferingDisplay(this.videoFormat, literales.getLiteral(StreamingLiterales.CARGANDO));
			dStreaming.initStatusDisplay(this.videoFormat, literales.getLiteral(StreamingLiterales.CONECTANDO));
			dStreaming.initVideo(this.videoFormat);
			
			switch (this.formato) {
				case Main.CUATROTERCIOS :
				case Main.DIECISEISNOVENOS :
					dStreaming.initMaximizeButton(this.videoFormat, literales.getLiteral(StreamingLiterales.MAXIMIZAR));
					break;
				case Main.RADIO :
					dStreaming.initLogo(this.logoFormat);
					dStreaming.initEslogan(this.esloganFormat);
					break;
				default :
			}
			
			dStreaming.fitScreen();
			Main.vStreaming = dStreaming;
		}
	}
}